﻿@model MiniBottles.Models.Bottle


@{
    var action = ViewContext.RouteData.Values["Action"];
}

<div class="fieldset">

         @Html.HiddenFor(model => model.Id)
         <div class="editor-label">
            @Html.LabelFor(model => model.DictCategory.DictCollection)
        </div>
        <div class="editor-field">
            @Html.DropDownList("DictCollection_Id", new SelectList(ViewBag.DictCollections, "Id", "Name",Model.DictCategory !=null ? Model.DictCategory.DictCollection.Id : 0))
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DictCategory)
        </div>
        <div class="editor-field">
            <div id="categorySection">
          
            </div>
            @Html.ValidationMessageFor(model => model.DictCategory)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
         <label>Miniaturka </label>
        </div>
        @if (ViewBag.ImageRequied !=null && ViewBag.ImageRequied)
        {
              <input type="file" data-val="true"  name="file"  data-val-required='Wybierz jakiś plik'  accept="image/jpeg,image/png,jpg|png" />
               @Html.ValidationMessage("file")
           
        }
        else
        {
            <input type="file"  name="file"  accept="image/jpeg,image/png,jpg|png" />
        }
       

    <div class="clear"></div>
        @if (!string.IsNullOrEmpty(Model.FileName)) 
        {
            <a href="~/Upload/big/@Model.FileName" rel="lightbox[roadtrip]" title="@Model.Name">
                <img  src="~/Upload/mini/@Model.FileName" />

            </a>
        }
        <div class="editor-label">
            @Html.LabelFor(model => model.Material)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Material)
            @Html.ValidationMessageFor(model => model.Material)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Alcohol)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Alcohol)
            @Html.ValidationMessageFor(model => model.Alcohol)
        </div>
         <div class="editor-label">
            @Html.LabelFor(model => model.Capacity)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Capacity)
            @Html.ValidationMessageFor(model => model.Capacity)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Country)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Country)
            @Html.ValidationMessageFor(model => model.Country)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
    
        <div class="editor-label">
            @Html.LabelFor(model => model.Order)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Order)
            @Html.ValidationMessageFor(model => model.Order)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.CreateDate)
        </div>
        <div class="editor-field">
            @Html.DisplayFor(model => model.CreateDate,"DateTimePicker")
            @Html.HiddenFor(model => model.CreateDate)
            
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UpdateDate)
        </div>
        <div class="editor-field">
            @Html.DisplayFor(model => model.UpdateDate,"DateTimePicker")
            @Html.HiddenFor(model => model.UpdateDate)
           
        </div>
      <br />
        <div class="editor-label">
            @Html.LabelFor(model => model.ToExchange)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ToExchange)
            @Html.ValidationMessageFor(model => model.ToExchange)
        </div>
        <br />
        <div class="editor-label">
            @Html.LabelFor(model => model.IsFavorite)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsFavorite)
            @Html.ValidationMessageFor(model => model.IsFavorite)
        </div>
      <br />
       <div class="editor-label">
            @Html.LabelFor(model => model.IsWanted)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsWanted)
            @Html.ValidationMessageFor(model => model.IsWanted)
        </div>
      <br />
        <div class="editor-label">
            @Html.LabelFor(model => model.IsActive)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.IsActive)
            @Html.ValidationMessageFor(model => model.IsActive)
        </div>
    </div>



<script>

    var collectionDdl = $('#DictCollection_Id');
    GetCategoryDropdownList(collectionDdl.val());
    collectionDdl.change(function (e) {

        var collectionId = $(this).val();
        GetCategoryDropdownList(collectionId);
    });

    function GetCategoryDropdownList(collectionId) {
        $.ajax({
            url: "@Url.Action("GetAllByCollection","DictCategory")",
             type: "POST",
             data: { collectionId: collectionId },
             success: function (data) {

                 $("#categorySection").html(data.content);

             }

         })
    }
</script>

